#!/usr/bin/env bash

if [ $# -lt 1 ]; then
    echo "Usage: $(basename $0) [patch dir/files]"
    exit -1
fi

files=$(grep -rIswl "rm.*\$[\(]depfile[\)]" $*)
if [ -z "${files}" ]; then
    echo "no files"
    exit 1
fi

echo "patching files:"
for f in ${files}; do
	echo "    ${f}"
done

# rm $(depfile) -> echo > /dev/null
sed -i  "s%rm.*depfile[\)]%echo > /dev/null%g" ${files}

